// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: wsfuyibing <682805@qq.com>
// Date: 2024-12-03

package errs

import (
	"gitee.com/go-libs/result"
	"net/http"
)

var (
	ErrClusterNotFound = result.NewError(404, `cluster deleted or not enabled`)
	ErrClusterTooMany  = result.NewError(400, `too many clusters are enabled`)

	ErrEndpointForFailedNotFound  = result.NewError(400, `endpoint for failed not configured`)
	ErrEndpointForSucceedNotFound = result.NewError(400, `endpoint for success not configured`)

	ErrFilterResponseBodyNotMatched = result.NewError(http.StatusBadRequest, `scheduler response body not match condition filter`)

	ErrPermissionAccountNotFound      = result.NewError(404, `permission account deleted or not enabled`)
	ErrPermissionApplicationNotFound  = result.NewError(404, `permission application deleted or not enabled`)
	ErrPermissionResourceNotFound     = result.NewError(404, `permission resource deleted or not enabled`)
	ErrPermissionResourceNotEmpty     = result.NewError(400, `permission resource has child items`)
	ErrRegistryNotFound               = result.NewError(404, `topic and tag not registered`)
	ErrSubscriptionNoInMemory         = result.NewError(404, `subscription deleted or disabled`)
	ErrUnsupportedNotificationMessage = result.NewError(400, `unknown notification message`)
)

// Error for http response.

var (
	ErrDatabaseError           = result.NewError(http.StatusInternalServerError, `server error`)
	ErrPluginNotSupported      = result.NewError(http.StatusBadRequest, `plugin not supported`)
	ErrServerManagerNotEnabled = result.NewError(http.StatusBadRequest, `server manager not enabled`)
	ErrServerManagerError      = result.NewError(http.StatusInternalServerError, `server manager error`)
	ErrSnapshotNotFound        = result.NewError(http.StatusNotFound, `snapshot not found`)
	ErrTaskNotFound            = result.NewError(http.StatusNotFound, `subscription task not found`)
)

var (
	ErrUserNotFound             = result.NewError(CodeUserNotFound, `user not found`)
	ErrUserPasswordNotMatch     = result.NewError(CodeUserPasswordNotMatch, `password not match`)
	ErrUserIssueToken           = result.NewError(CodeUserIssueToken, `issue access token failed`)
	ErrUserUnauthorized         = result.NewError(http.StatusUnauthorized, `unauthorized`)
	ErrUserInvalidAuthorization = result.NewError(http.StatusUnauthorized, `invalid authorized`)
	ErrUserStatusDisabled       = result.NewError(http.StatusForbidden, `disabled user`)
	ErrUserStatusLocked         = result.NewError(http.StatusForbidden, `locked user`)
)
